/*请求url*/
var urlData = require('../../../../../data/url.js'),
	requireData = require('../../../../../data/select.js');

Page({
	data:{
		index:0,
		array:requireData.requireList.dateArray,
		userId:0,
		userName:0,
		userRole:0,
		/*url*/
		socreQueryUrl:urlData.urlList.homeSchoolManage.score.scoreQuery.url
	},
	onLoad:function(e){
		var that = this;
		wx.getStorage({
	        key : 'loginConf',
	        success : function(res){
	            console.log(res)
	            that.setData({
	                userId : res.data.userId,
	                userName : res.data.userName,
	                userRole : res.data.userRole
	            });
	        }
	    });
	},
	bindPickerChange: function(e) {
	    this.setData({
	      index: e.detail.value
	    })
	},
	submit:function(e){
		wx.request({
		    url: this.data.socreQueryUrl, //仅为示例，并非真实的接口地址
		    data: {
		    	term : this.data.index+1,
		    	user_id : this.data.userId,
		    	role : this.data.userRole
		    },
		    method:"get",
		    header: {'content-type': 'application/x-www-form-urlencoded'}, 
		    success: function(res) {
		    	if(res.data.code == 0){
		    		console.log(res.data.list)
		    		wx.setStorage({//写入本地数据缓存
					    key:"scoreConf",
					    data:{
					    	scoreList : res.data.list
					    }
					});
		    		wx.navigateTo({
				        url: '../score-detail/score-detail'
				    })
		    	}
		    }
	    })
	}
});

